#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
#import seaborn as sns
#from matplotlib.font_manager import FontProperties

path = './data/njdt_20210108_000105_559_3.rda'

def get_correlated_dataset(n):
    """
    满足高斯分布数据集形式
    :param n: 个数
    :return:
    """
    verbose = 'gaussian'
    np.random.seed(0)
    dependency = [[9, -0.6],
                  [0.1, -0.6]]
    mu = 2, 4
    scale = 3, 5
    latent = np.random.randn(n, 2)
    dependent = latent.dot(dependency)
    scaled = dependent * scale
    scaled_with_offset = scaled + mu
    # return x and y of the new, correlated dataset
    return scaled_with_offset[:, 0], scaled_with_offset[:, 1], verbose


def sinc_function(scale):
    """
    sinc函数数据集
    :param scale: 倍数
    :return:
    """
    verbose = 'sinc'
    x = np.arange(0, 2 * np.pi, 0.1)
    y = np.sinc(x) * scale
    return x, y, verbose


def read_data_file(path):
    """
    对电厂数据进行读取
    :return:
    """
    verbose = path.split('/')[-1].split('.')[0]
    df = pd.read_csv(path, sep='\t')
    df = df.reset_index(drop=False)
    df.columns = ['时间轴', '地址', '时间戳', '负荷']
    data = df.drop(['地址', '时间戳'], axis=1)
    #myfont = FontProperties(fname=r'C:\Windows\Fonts\simhei.ttf', size=14)
    #sns.set(font=myfont.get_name())
    #g = sns.lmplot(x="时间轴", y="负荷", data=data)
    #g.savefig('./img/{value}电厂数据可视化效果.jpg'.format(value=verbose))
    x = data['时间轴'].tolist()
    y = data['负荷'].tolist()

    return x, y, verbose

if __name__ == "__main__":

    x, y = read_data_file(path=path)

